home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / manageme / tcpdump-.001 / tcpdump-~ / tcpdump-3.0.2-linux / tcpdump-3.0.2 / print-sunrpc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-15  |  3.2 KB  |  118 lines

  1. /*
  2.  * Copyright (c) 1992, 1993, 1994
  3.  *    The Regents of the University of California.  All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that: (1) source code distributions
  7.  * retain the above copyright notice and this paragraph in its entirety, (2)
  8.  * distributions including binary code include the above copyright notice and
  9.  * this paragraph in its entirety in the documentation or other materials
  10.  * provided with the distribution, and (3) all advertising materials mentioning
  11.  * features or use of this software display the following acknowledgement:
  12.  * ``This product includes software developed by the University of California,
  13.  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
  14.  * the University nor the names of its contributors may be used to endorse
  15.  * or promote products derived from this software without specific prior
  16.  * written permission.
  17.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  18.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  19.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  20.  */
  21.  
  22. #ifndef lint
  23. static char rcsid[] =
  24.     "@(#) $Header: print-sunrpc.c,v 1.12 94/06/14 20:18:48 leres Exp $ (LBL)";
  25. #endif
  26.  
  27. #include <sys/param.h>
  28. #include <sys/time.h>
  29. #include <sys/types.h>
  30. #include <sys/socket.h>
  31.  
  32. #include <net/if.h>
  33.  
  34. #include <netinet/in.h>
  35. #include <netinet/if_ether.h>
  36. #include <netinet/in_systm.h>
  37. #include <netinet/ip.h>
  38. #include <netinet/ip_var.h>
  39.  
  40. #ifdef SOLARIS
  41. #include <tiuser.h>
  42. #endif
  43. #include <rpc/types.h>
  44. #include <rpc/auth.h>
  45. #include <rpc/auth_unix.h>
  46. #include <rpc/svc.h>
  47. #include <rpc/xdr.h>
  48. #include <rpc/rpc_msg.h>
  49. #include <rpc/pmap_prot.h>
  50.  
  51. #include <ctype.h>
  52. #include <errno.h>
  53. #include <stdio.h>
  54.  
  55. #include "interface.h"
  56. #include "addrtoname.h"
  57. #include "extract.h"            /* must come after interface.h */
  58.  
  59. #if BYTE_ORDER == LITTLE_ENDIAN
  60. static void bswap(u_int32 *, u_int);
  61. #endif
  62.  
  63. #if BYTE_ORDER == LITTLE_ENDIAN
  64. /*
  65.  * Byte swap an array of n 32-bit words.
  66.  * Assume input is word-aligned.
  67.  * Check that buffer is bounded by "snapend".
  68.  */
  69. static void
  70. bswap(register u_int32 *bp, register u_int n)
  71. {
  72.     register int nwords = ((char *)snapend - (char *)bp) / sizeof(*bp);
  73.  
  74.     if (nwords > n)
  75.         nwords = n;
  76.     for (; --nwords >= 0; ++bp)
  77.         *bp = ntohl(*bp);
  78. }
  79. #endif
  80.  
  81. static struct token proc2str[] = {
  82.     { PMAPPROC_NULL,    "null" },
  83.     { PMAPPROC_SET,        "set" },
  84.     { PMAPPROC_UNSET,    "unset" },
  85.     { PMAPPROC_GETPORT,    "getport" },
  86.     { PMAPPROC_DUMP,    "dump" },
  87.     { PMAPPROC_CALLIT,    "call" },
  88.     { 0,            NULL }
  89. };
  90.  
  91. void
  92. sunrpcrequest_print(register const u_char *bp, register int length,
  93.             register const u_char *bp2)
  94. {
  95.     register const struct rpc_msg *rp;
  96.     register const struct ip *ip;
  97.  
  98.     rp = (struct rpc_msg *)bp;
  99.     ip = (struct ip *)bp2;
  100.  
  101.     if (!nflag)
  102.         (void)printf("%s.%x > %s.sunrpc: %d",
  103.                  ipaddr_string(&ip->ip_src),
  104.                  ntohl(rp->rm_xid),
  105.                  ipaddr_string(&ip->ip_dst),
  106.                  length);
  107.     else
  108.         (void)printf("%s.%x > %s.%x: %d",
  109.                  ipaddr_string(&ip->ip_src),
  110.                  ntohl(rp->rm_xid),
  111.                  ipaddr_string(&ip->ip_dst),
  112.                  PMAPPORT,
  113.                  length);
  114.     printf(" %s", tok2str(proc2str, " proc #%d",
  115.                   ntohl(rp->rm_call.cb_proc)));
  116. }
  117.  
  118.